#pragma once
#include <opencv/cv.h>
#include <vector>
#include "ThresholdEntropy.h"
#include "MorphologicalOperation.h"


using namespace std;

/**
 *
 * @author DengNianchen
 */
class LinearHT
{
private:

	vector< vector< int > > _houghArray;
	vector< double > _cosTable;
	vector< double > _sinTable;
	int _maxHoughValue;
	int _angleStep;
	int _radiusStep;
	double _deltaAngle;
	double _deltaRad;
	int _directDetectSize;
	vector< int > _tableIndex;
	ThresholdEntropy _thresh;
	MorphologicalOperation _morphological;

	IplImage* _houghArrayImage;
	IplImage* _localMaxImage;

	void _fillHoughArray (double x, double y, int neighIndex);
	void _compareAndClear (int x, int y, int nx, int ny);

public:

	LinearHT (int angleStep, int radiusStep, int directDetectSize);

	~LinearHT ();

	vector< CvPoint2D64f > findLine (IplImage * inImage);

	void fillHoughArray (IplImage * outImage);

	vector< CvPoint2D64f > getLines ();

	vector< vector< int > >& getHoughArray ();

};